package com.xugui.thumb.controller;

import com.xugui.thumb.pojo.common.BaseResponse;
import com.xugui.thumb.pojo.common.ResultUtils;
import com.xugui.thumb.pojo.dto.DoThumbRequest;
import com.xugui.thumb.services.ThumbService;
import jakarta.servlet.http.HttpServletRequest;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("thumb")
@RequiredArgsConstructor
public class ThumbController {  

    private final ThumbService thumbService;

    /**
     * 点赞接口
     * @param doThumbRequest 点赞请求
     * @param request 请求
     * @return 点赞结果
     */
    @PostMapping("/do")
    public BaseResponse<Boolean> doThumb(@RequestBody DoThumbRequest doThumbRequest, HttpServletRequest request) {
        Boolean success = thumbService.doThumb(doThumbRequest, request);  
        return ResultUtils.success(success);
    }

    /**
     * 取消点赞接口
     * @param doThumbRequest 取消点赞请求
     * @param request 请求
     * @return 取消点赞结果
     */
    @PostMapping("/undo")
    public BaseResponse<Boolean> undoThumb(@RequestBody DoThumbRequest doThumbRequest, HttpServletRequest request) {
        Boolean success = thumbService.undoThumb(doThumbRequest, request);
        return ResultUtils.success(success);
    }
}
